<?php

if(!function_exists("readline")){
   function readline($prompt){
       echo $prompt;
       return stream_get_line(STDIN, 1024, PHP_EOL);
   }
}

class McCube_Shell
   extends McCube_Shell_Color {

   public function prompt($txt, $choice=''){
       $txtChoice = '';
       if($choice)
           $txtChoice = ' ['.$choice.']';

       if(!($input = readline($txt.$txtChoice)))
           $input = $this->prompt($txt, $choice);

       if($choice){
           $_choice = explode('|', $choice);
           if(!in_array($_choice, $input))
               $input = $this->prompt($txt, $choice);
       }

       return $input;
   }

}